<%--
<ANNOTATION.PAGE>
	<fileName> usermgmt_test.jsp </fileName>
	<author> KFZX-yuli1 </author>
	<createDate> 2010-6-7  上午10:42:31 </createDate>
	<lastModifier> 2010-6-7  上午10:42:31 </lastModifier>
	<lastModifyDate> 2010-6-7  上午10:42:31 </lastModifyDate>
	<description></Description>
</ANNOTATION.PAGE>
--%>
<%--
	fileName      : usermgmt.jsp
	author        : KFZX-yuli1
	createDate    : 2010-6-7  上午10:42:31
	lastModifier  : KFZX-tangk
	lastModifyDate: 2010-6-7  上午10:42:31
	description   : 请添加描述
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="ctp-tag" prefix="ctp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">		
		<ctp:include items='borderlayout,layout,panel,toolbar,textfield,button,tabletree,combobox,form,validididididator,textarea,label,lightlayout,groupbox,menus,grid,statusbar,radiogroup,checkbox,checkboxgroup,message_ex'/>
		<%@ include file="/branch/branchlist.jsp" %>
		<%@ include file="/uniform_attestation/ssicPub.jsp" %>
		<script type='text/javascript' kind='variant'>		  
		     //================================UI变量定义片段============================================================
		//ctp.core.log.lvl=ctp.core.loglvl.obj;
		var toolbar;//定义工具栏
		var gridBody;//定义表体
		var gridHeader;//定义表头
		var borderlayout;
		 </script>
		
		<script type='text/javascript' kind='event'>
            //================================函数定义片段============================================================
		
			var temp;
			var myurl;
			var branchId ='<ctp:out name="flowCtx.branchId"/>';
			var Language ='<ctp:out name="sessCtx.Language"/>';
			var branchName ='<ctp:out name="flowCtx.branchName"/>';
			var defualtRoleId='<ctp:out name="sessCtx.defaultRoleId"/>';	
			var v_flag='<ctp:out name="out_flag" />';
		     /**
             * 删除用户，确认是否删除的部分在申明控件的部分定义，此处直接删除操作，并返回是否成功
             	另：删除需统一认证双人授权，在此方法的最后部分。
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-yuli1           
             */		
			function userDel(tp){
				
				if(tp=='ok'){

					function submit(){
	            		
	            		var _id=temp.id
							ctp.data.getJSONA({
								url:'<ctp:url href="user.flowc" flowActionName="deleteuserop"/>&userId='+_id+'&objId='+_id,
								success:function(data){
										if(data[0].out_flag &&data[0].out_flag=="0"){
										
							ctpMSB.succeed({title:'<ctp:label key="result"/>',message:'<ctp:label key="del_user_success"/>',handler: handler_operation});
		                              	
						}else{
							ctpMSB.error({title:'<ctp:label key="result"/>',message:'<ctp:label key="del_user_fail"/>'});
						}
						}
					} );
				}
					if(('1'=='<ctp:out name="servCtx.authFlag"/>')&&('true'=='<ctp:out name="servCtx.enableSSIC"/>')){
	             		result=ssicAuth('<ctp:out name="fullPath"/>user.flowc','deleteuserop',submit,"0");		             	
	            	}else{
	            			submit();
	            	}		
	            	
				}
				else if(tp=='cancel'){
					ctpMSB.close();   
				}
				else if(tp=='close'){
					
					ctpMSB.close();   
				}
			}
			
			
			 /**
             * 回调函数，删除后刷新表树
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-yuli1           
             */
			
			
		       function handler_operation(){
		       var _mContext = "usermgmt.jsp -> handler_operation()";  
		       try {  
		       				//删除成功后刷新表树和重置按钮状态
		                    gridBody.loadData(myurl);
		                    toolbar.setDisable("button2",true);
							toolbar.setDisable("button3",true);
							toolbar.setDisable("button4",true);
							toolbar.setDisable("button5",true);
							toolbar.setDisable("button6",true);
		             }
		            catch (e) {
		                     ctp.core.log.err(_mContext, e.message);
		            }             
		          }
			
		
		     /**
             * 当点击用户列表行时，设置用户表单对应组件的值
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-yuli1           
             */
			function setDetailValue(){
				 temp=gridBody.getSelectedData()[0];
				 toolbar.setDisable("button2",false);
				 toolbar.setDisable("button3",false);
				 toolbar.setDisable("button4",false);
				 toolbar.setDisable("button5",false);
				 toolbar.setDisable("button6",false);
				 ctpform.setHiddenValue("branchId",'<ctp:out name="branchId"/>');
	    		 ctpform.setHiddenValue("userId",temp.id);

			}
			
			function initJSP(){		
				gridBody.selectedFn(setDetailValue);
			}
					
        </script>
		<script type='text/javascript' kind='ui'>
		    //================================UI组件定义片段============================================================		    
		    //ctp.core.log.lvl = ctp.core.loglvl.obj; //需要进行调试时启用
		    /**
             * 创建UI组件
             * @version	 1.0
             * @since	 1.0
             * @author	kfzx-yuli1           
             */		    
		    function initUI(){
		         if(v_flag=='2'){
		       	    ctpMSB.error({title:'<ctp:label key="result"/>',message:'<ctp:label key="exist_user"/>'});
		         }					
				 toolbar=new ctp.ui.toolbar({
					id : 'toolbarId',			
					border : 'bottom',			
				    leftItems :[
				    	{//新增用户
						id:"button1",
				        type : 'button',
				        text : '<ctp:label key="newinbutton"/>',
				        icon : 'add',
				        onClick : function(){
				        ctpform.setHiddenValue("userType",'1');
				        ctpform.submit();
				        }},'-',
				        {//修改用户
						id:"button2",
				        type : 'button',
				        text : '<ctp:label key="modbutton"/>',
				        icon : 'edit',
				        disabled : true,
				        onClick : function(){
				        ctpform.setHiddenValue("userType",'0');
				        ctpform.submit();
				        }},'-',
				        {//删除用户
						id:"button3",
				        type : 'button',
				        text : '<ctp:label key="delbutton"/>',
				        icon : 'delete',
				        disabled : true,
				        onClick : function(){
						ctpMSB.confirm({message:'<ctp:label key="delthisuser_willdel_connect_withit"/>',handler:userDel});
				        }},'-',
				        {//用户菜单预览
						id:"button4",
				        type : 'button',
				        text : '<ctp:label key="usermenu_preview"/>',
				        icon : 'pre_print',
				        disabled : true,
				        onClick : function(){
				        var srcPath = '<ctp:url href="user.flowc" flowActionName="changerolepreview"/>&userIdSel=' +temp.id+'&roleIdSel='+temp.defaultRole;
				        
				        ctpMSB.win({
			            message   :srcPath,
			            width     :'700',
			            height    :'500',
			            title     :'<ctp:label key="usermenu_preview"/>',
			            maxBtn    :true,
			            iframe    :true});
				        }},'-',
				        {//用户菜单修改
						id:"button5",
				        type : 'button',
				        text : '<ctp:label key="usermenu_modify"/>',
				        icon : 'role-setup',
				        disabled : true,
				        onClick : function(){
						document.menumodify.userId.value=temp.id;
				        document.menumodify.submit();
				        }},'-',{
				        //查看用户详细信息
						id:"button6",
				        type : 'button',
				        text : '<ctp:label key="view"/>',
				        icon : 'search',
				        disabled : true,
				        onClick : function(){
				        
				     	var srcPath = '<ctp:url href="user.flowc" flowActionName="userdetailop"/>&userId=' +temp.id+'&Language='+'<ctp:out name="sessCtx.Language" /> ';
				        ctpMSB.win({
			            message   :srcPath,
			            width     :700,
			            height    :400,
			            title     :'<ctp:label key="userinfo"/>',
			            maxBtn    :true,
			            minBtn    :true,
			            iframe    :true});
			            }},'-',
			            {//返回
						id:"button7",
				        type : 'button',
				        text : '<ctp:label key="returnbutton"/>',
				        icon : 'back',
				        onClick : function(){
				        document.menumodify.flowActionName.value='branchlistjsp';
						document.menumodify.submit();
				        }}]
				});
				 myurl='<ctp:url href="user.flowc" flowActionName="userquerylist"  />';
				 gridHeader= new ctp.ui.grid.header({
			        title:[
			        //定义列头
			        [{
			            text:'<ctp:label key="returnbutton"/>'//全选/全不选
			        },{
			            text: '<ctp:label key="SerialNo"/>'//序号
			        }, {
			            text: '<ctp:label key="user_code"/>'//用户编号
					}, {
			            text: '<ctp:label key="user_name"/>'//用户名称
			        }, {
			            text: '<ctp:label key="user_state"/>'//用户状态
			        }, {
			            text: '<ctp:label key="user_branch"/>'//所属机构
			        }]],
			        rowIdFieldName:"id",
			        attr: [
			        	//定义列表内容
			    		{
			    			colType:"radiobox" //列表属性单选框                   		
			    		},
			    		{
			    			colType:"seqnum" //列表属性序号
			    		},
			         	{
			            	fieldName: "id"	//数据来自vjson
			        	},
			        	{
			        		fieldName: "name"	//数据来自vjson
			        	},
			        	{
			        		fieldName: "status"	//数据来自vjson
			        	},
			        	{
			        		fieldName: "branchName"	//数据来自vjson
			        	}
			        ]
			     });
			     gridBody = new ctp.ui.grid({
			     	id: "gridId",
			    	header: gridHeader,
			    	title: '<ctp:label key="user_branch"/>'+':'+'<ctp:out name="flowCtx.branchName" />',
					width:"auto",
					height:"100%",
					toolbar:toolbar,
                    toolbarPos:'innertop',					
					url:myurl,
					footer:new ctp.ui.grid.footer({showRows:10,cacheRows:20})
				 });
				 
			 
			 
				ctpform=new ctp.form({
					id: 'useradd',
					width: '90%', //宽度
					postType:'normal'
				});

				borderlayout=new ctp.ui.borderlayout({
                    type: "1C",                    
                    center__size: "auto",
                    center__items:[gridBody],
                    renderTo:'body'
                }); 
			};

		
		</script>
	</head>
<body  onload='initUI();initJSP();'>


<ctp:form name="useradd" method="post" action="user.flowc" flowActionName="addUserSwitch">
	<input type="hidden" name="branchId"/>
	<input type="hidden" name="userId"/>
	<input type="hidden" name="userType" />
</ctp:form> 

<ctp:form name="menumodify" method="post" action="user.flowc" flowActionName="modifymenujsp">
	<input type="hidden" name="userId"/>
</ctp:form> 

</body>
</html>

<%--
	date        :
	modifyReason:
--%>